#!/usr/bin/perl -w # useful for syntax highlighting

package clreqd_modules;

sub diskhb_devsize {
my %ARGS=@_;
my $get_dev_size="$::ENV{TRUECL_CODE}/utils/get-dev-size";

	local  $SIG{CHLD}='DEFAULT';
	if($^O eq "solaris") {
		if(! -x "/usr/sbin/devinfo") {
			return "ERROR: Unable to find utility '/usr/sbin/devinfo'.";
		}
		my $r=`/usr/sbin/devinfo -p $ARGS{DEVNAME} 2>&1`;
		chomp $r;
		my @F=split(/\s+/,$r);
		if(!defined($F[4]) || $F[4] !~ /^\d+$/) {
			return "ERROR $r";
		}
		return "OK $F[4]";
	}
	if(! -x $get_dev_size) {
		return "ERROR: Unable to find utility '$get_dev_size'.";
	}
	my $r=`$get_dev_size $ARGS{DEVNAME} 2>&1`;
	chomp $r;
	if($r =~ /^Error:/i) {
		$r =~ s/^Error:\s+//i;
		return "ERROR $r";
	}
	return "OK $r";
}
1;
